  {if $smarty.get.print != 1}
  {include file="header.tpl"}
{else}
  <table width="100%">
    <td width="33.33%"><img src="./images/shreeSava.jpg" /></td>
    <td width="33.33%" align="center"><img src="./images/shreeGanesh.jpg" /></td>
    <td width="33.33%" align="right"><img src="./images/shreeGelMataji.jpg" /></td>
  </table>
{/if}
<style>
.aavakColor
{
  color:red;
}
.javakColor
{
  color:green;
}
</style>
<script type="text/javascript">
function deleteRow(bhatthiId)
{
  if(confirm("Warning: Are you sure?\nDeletion is permanent. Continue anyway.") && confirm("Warning: Are you sure?\nDeletion is permanent. Continue anyway."))
  {
    location.href = "deleteBhatthiBook.php?bhatthiId="+bhatthiId;
  }
}
</script>
<script type="text/javascript">
function bookFunction(id)
{ 
  document.form.bdate .value="1";
  document.form.submit();
}
</script>
<form name="form" action="" method="post">
<input type="hidden" name="bdate" id="bdate" value="0" />
<center><b>{$l_bhatthiDetail}</b></center>
<div class="contentDiv">
  <table border="0" align="center" width="100%" cellspacing="0" cellpadding="2" >
  <tr>
    <td class="table1">
      {$l_partySelect} : 
      <select name="party" onchange="bookFunction()">
        <option value="0">{$l_partySelect}</option>
        {html_options values=$party.id output=$party.name selected={$partyId}}
      </select>
    </td>
    <td class="table1">
      {$l_from} : {html_select_date prefix="fromDate" start_year="-2" end_year="+1" field_order="DMY" day_value_format="%02d" time=$fromDateSelected}
      {$l_to} : {html_select_date prefix="toDate" start_year="-2" end_year="+1" field_order="DMY" day_value_format="%02d" time=$toDate}
      <input type="submit" name="submitBtn" value="{$l_find}" />
      {if $smarty.get.print!=1}
        <td class="table1"><a href="bhatthiDetail.php?print=1&fromDate={$fromDate}&toDate={$toDate}&party={$partyId}">Print</a></td>
      {else}
        &nbsp;
      {/if}
    </td>
  </tr>
  {if $smarty.get.print != 1}
    {else}
    <tr class="table2"><td colspan="10"><hr COLOR="#000000" /></td></tr>
    {/if}
  <tr>
    <th colspan="2" align="center" class="aavakColor">{$l_credit}</th>
  </tr>
  {if $smarty.get.print != 1}
    {else}
    <tr class="table2"><td colspan="10"><hr COLOR="#000000" /></td></tr>
    {/if}
  <tr align="center">
    <td colspan="2" align="center">
    <table border="1" align="center" width="100%" cellspacing="0" cellpadding="1" class="aavakColor">
      <tr class="table1">
        <th align="left">&nbsp;</th>
        <th>{$l_date}</th>
        <th>Particulars</th>
        <th>gross Weight</th>
        <th>Ghat</th>
        <th>{$l_weight}</th>
        <th>{$l_touch}</th>
        <th>{$l_fine}</th>
        <th>{$l_qty}</th>
        <th>{$l_rate}</th>
        <th>Amt</th>
      </tr>
      <tr>
        <td width="8%">&nbsp;</td>
        <td width="8%">&nbsp;</td>
        <td width="25%">Opening</td>
        <td width="7%" align="right" style="border-right:1px solid;">&nbsp;</td>
        <td width="7%" align="right" style="border-right:1px solid;">&nbsp;</td>
        <td width="7%" align="right" style="border-right:1px solid;">&nbsp;</td>
        <td width="7%" align="right" style="border-right:1px solid;">&nbsp;</td>
        <td width="7%" align="right" style="border-right:1px solid;">{if $openingFinalFineCr != 0}{$openingFinalFineCr|string_format:"%.0f"}{else}&nbsp;{/if}</td>
        <td width="7%" align="right" style="border-right:1px solid;">&nbsp;</td>
        <td width="7%" align="right" style="border-right:1px solid;">&nbsp;</td>
        <td width="7%" align="right">{if $openingFinalAmountCr != 0}{$openingFinalAmountCr|string_format:"%.0f"}{else}&nbsp;{/if}</td>
      </tr>
      {section name=crSec loop=$bhatthiBookCr|@count}
        <tr>
          <td NOWRAP>
            {if $smarty.get.print != 1}
              {if $bhatthiBookCr[crSec].bhatthiBookId != $bhatthiBookCr[$smarty.section.crSec.index-1].bhatthiBookId}<a href="bhatthiDetailAavak.php?print=1&bhatthiBookId={$bhatthiBookCr[crSec].bhatthiBookId}&bhatthiPartyId={$bhatthiBookCr[crSec].bhatthiPartyId}&bhatthiDate={$bhatthiBookCr[crSec].date}">Print</a>{else}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{/if}
              {if $bhatthiBookCr[crSec].bhatthiBookId != $bhatthiBookCr[$smarty.section.crSec.index-1].bhatthiBookId}<a href="javascript:deleteRow({$bhatthiBookCr[crSec].bhatthiBookDetailId})"><img src="./images/b_drop.png" border="0" width="15" height="15"></a>{else}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{/if}
              {if $bhatthiBookCr[crSec].bhatthiBookId != $bhatthiBookCr[$smarty.section.crSec.index-1].bhatthiBookId}<a href="bhatthiCreditEntry.php?bhatthiBookId={$bhatthiBookCr[crSec].bhatthiBookId}"><img src="./images/b_edit.png" border="0" width="15" height="15"></a>{else}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{/if}
            {else}
            {/if}
          </td>
          <td NOWRAP align="center">{$bhatthiBookCr[crSec].date|date_format:"%d-%m-%Y"}</td>
          <td NOWRAP>{$bhatthiBookCr[crSec].particulars}</td>
          <td align="right" style="border-right:1px solid;">{if $bhatthiBookCr[crSec].grossWeight != 0}{$bhatthiBookCr[crSec].grossWeight|string_format:"%.0f"}{else}&nbsp;{/if}</td>
          <td align="right" style="border-right:1px solid;">{if $bhatthiBookCr[crSec].diffWeight != 0}{$bhatthiBookCr[crSec].diffWeight|string_format:"%.0f"}{else}&nbsp;{/if}</td>
          <td align="right" style="border-right:1px solid;">{if $bhatthiBookCr[crSec].weight != 0}{$bhatthiBookCr[crSec].weight|string_format:"%.0f"}{else}&nbsp;{/if}</td>
          <td align="right" style="border-right:1px solid;">{if $bhatthiBookCr[crSec].touch != 0}{$bhatthiBookCr[crSec].touch|string_format:"%.2f"}{else}&nbsp;{/if}</td>
          <td align="right" style="border-right:1px solid;">{if $bhatthiBookCr[crSec].fine != 0}{$bhatthiBookCr[crSec].fine|string_format:"%.0f"}{else}&nbsp;{/if}</td>
          <td align="right" style="border-right:1px solid;">{if $bhatthiBookCr[crSec].qty != 0}{$bhatthiBookCr[crSec].qty|string_format:"%.0f"}{else}&nbsp;{/if}</td>
          <td align="right" style="border-right:1px solid;">{if $bhatthiBookCr[crSec].rate != 0}{$bhatthiBookCr[crSec].rate|string_format:"%.2f"}{else}&nbsp;{/if}</td>
          <td align="right" style="border-right:1px solid;">{if $bhatthiBookCr[crSec].amount != 0}{$bhatthiBookCr[crSec].amount|string_format:"%.0f"}{else}&nbsp;{/if}</td>
        </tr>
      {/section}
      {section name="sec1" loop=$extraBhatthiBookCr}
      {/section}
   <tr><td colspan="12"><hr COLOR="#000000" /></td></tr>
      <tr class="table1">
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;{$l_total}</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td align="right">{$totalFineCr|string_format:"%.0f"}</td>
        <td align="right">{$total.crQty|string_format:"%.0f"}</td>
        <td>&nbsp;</td>
        <td align="right">{$totalAmountCr|string_format:"%.0f"}</td>
      </tr>
    </table>
    </td>
  </tr>
    {if $smarty.get.print != 1}
    {else}
    <tr class="table2"><td colspan="10"><hr COLOR="#000000" /></td></tr>
    {/if}
  <tr class="table1">
    <th colspan="2" class="javakColor">{$l_debit}</th>
  </tr>
  {if $smarty.get.print != 1}
    {else}
    <tr class="table2"><td colspan="10"><hr COLOR="#000000" /></td></tr>
    {/if}
  <tr class="">  
    <td vAlign="top" colspan="2">
    <table border="1" align="center" width="100%" cellspacing="0" cellpadding="1"   class="javakColor">
      <tr class="table1">
      	<td>&nbsp;</td>
      	<th>{$l_date}</th>
      	<th>Particulars</th>
      	<th>gross Weight</th>
      	<th>Ghat</th>
        <th>{$l_weight}</th>
        <th>{$l_touch}</th>
        <th>{$l_fine}</th>
        <th>{$l_qty}</th>
        <th>{$l_rate}</th>
        <th>Amt</th>
      </tr>
      <tr>
      	<td width="8%">&nbsp;</td>
      	<td width="8%">&nbsp;</td>
      	<td width="25%">Opening</td>
      	<td width="7%">&nbsp;</td>
      	<td width="7%">&nbsp;</td>
      	<td width="7%">&nbsp;</td>
      	<td width="7%">&nbsp;</td>
      	<td width="7%" align="right">{if $openingFinalFineDr != 0}{$openingFinalFineDr|string_format:"%.0f"}{else}&nbsp;{/if}</td>
      	<td width="7%">&nbsp;</td>
      	<td width="7%">&nbsp;</td>
        <td width="7%" align="right">{if $openingFinalAmountDr != 0}{$openingFinalAmountDr|string_format:"%.0f"}{else}&nbsp;{/if}</td>
      </tr>
      {section name="drSec" loop=$bhatthiBookDr|@count}
        <tr>
          <td>
            {if $smarty.get.print != 1}
              {if $bhatthiBookDr[drSec].bhatthiBookId != $bhatthiBookDr[$smarty.section.drSec.index-1].bhatthiBookId}<a href="bhatthiDetailJavak.php?print=1&bhatthiBookId={$bhatthiBookDr[drSec].bhatthiBookId}&bhatthiPartyId={$bhatthiBookDr[drSec].bhatthiPartyId}&bhatthiDate={$bhatthiBookDr[drSec].date}">Print</a>{else}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{/if}
              {if $bhatthiBookDr[drSec].bhatthiBookId != $bhatthiBookDr[$smarty.section.drSec.index-1].bhatthiBookId}<a href="javascript:deleteRow({$bhatthiBookDr[drSec].bhatthiBookDetailId})"><img src="./images/b_drop.png" border="0" width="15" height="15"></a>{else}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{/if}
              {if $bhatthiBookDr[drSec].bhatthiBookId != $bhatthiBookDr[$smarty.section.drSec.index-1].bhatthiBookId}<a href="bhatthiDebitEntry.php?bhatthiBookId={$bhatthiBookDr[drSec].bhatthiBookId}"><img src="./images/b_edit.png" border="0" width="15" height="15"></a>{else}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{/if}
            {else}
            {/if}
          </td>
          <td NOWRAP align="center">{$bhatthiBookDr[drSec].date|date_format:"%d-%m-%Y"}</td>
          <td>{$bhatthiBookDr[drSec].particulars}</td>
          <td align="right" style="border-right:1px;">{if $bhatthiBookDr[drSec].weightPerc != 0}{$bhatthiBookDr[drSec].weightPerc|string_format:"%.0f"}{else}&nbsp;{/if}</td>
          <td align="right" style="border-right:1px;">{if $bhatthiBookDr[drSec].diffWeight != 0}{$bhatthiBookDr[drSec].diffWeight|string_format:"%.0f"}{else}&nbsp;{/if}</td>
          <td align="right" style="border-right:1px;">{if $bhatthiBookDr[drSec].grossWeight != 0}{$bhatthiBookDr[drSec].grossWeight|string_format:"%.0f"}{else}&nbsp;{/if}</td>
          <td align="right" style="border-right:1px;">{if $bhatthiBookDr[drSec].touch != 0}{$bhatthiBookDr[drSec].touch|string_format:"%.2f"}{else}&nbsp;{/if}</td>
          <td align="right" style="border-right:1px;">{if $bhatthiBookDr[drSec].fine != 0}{$bhatthiBookDr[drSec].fine|string_format:"%.0f"}{else}&nbsp;{/if}</td>
          <td align="right" style="border-right:1px;">{if $bhatthiBookDr[drSec].qty != 0}{$bhatthiBookDr[drSec].qty|string_format:"%.0f"}{else}&nbsp;{/if}</td>
          <td align="right" style="border-right:1px;">{if $bhatthiBookDr[drSec].rate != 0}{$bhatthiBookDr[drSec].rate|string_format:"%.0f"}{else}&nbsp;{/if}</td>
          <td align="right" style="border-right:1px;">{if $bhatthiBookDr[drSec].amount != 0}{$bhatthiBookDr[drSec].amount|string_format:"%.0f"}{else}&nbsp;{/if}</td>
        </tr>
      {/section}
      {section name="sec1" loop=$extraBhatthiBookDr}
      {/section}
      <tr><td colspan="60"><hr COLOR="#000000" /></td></tr>
      <tr class="table1">
        <td>&nbsp;</td>
        <td>&nbsp;</td>
         <td>{$l_total}</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td align="right">{$totalFineDr|string_format:"%.0f"}</td>
       <td align="right">{$total.drQty|string_format:"%.0f"}</td>
        <td>&nbsp;</td>
        <td align="right">{$totalAmountDr|string_format:"%.0f"}</td>
      </tr>
    </table>
    </td>

    
    
  </tr>
  <tr>
    <td colspan="2"><b style="color:green">{if $total.totFine >= 0} Total Debit Fine:{else}</b><b style="color:red"> Total Credit Fine:{/if}  {$total.totFine|string_format:"%.0f"} </b><br/>
                    <b style="color:green">{if $total.totAmount >= 0} Total Debit Amount:{else}</b><b style="color:red"> Total Credit Amount:{/if}  {$total.totAmount|string_format:"%.0f"}</b></td>
  </tr>
  </table>
</div>
</form>
{if $smarty.get.print != 1}
  {include file="footer.tpl"}
{/if}
